layui.use('layer', function(){ //独立版的layer无需执行这一句
  var  layer = layui.layer; 
});

layui.use('form', function(){
 var form = layui.form;
  
});
layui.use('element', function(){
  var element = layui.element;
  
 
});
layui.use('laydate', function(){
  var laydate = layui.laydate;
lay('.date').each(function(){
    laydate.render({
      elem: this
      ,trigger: 'click'
	  ,format: 'yyyy/MM/dd' 
    });
  });
  });
  

layui.use(['upload','jquery'], function(){
	var upload = layui.upload
  

var tipsi;
$(".tips").hover(function(){
var info=$(this).attr("tips")  
  tipsi = layer.tips(info,this,{time:0});
   },function(){
		layer.close(tipsi);
   });


 
 var uploadInst = upload.render({
    elem: '.upload'
    ,url: '../upload/'
    ,before: function(obj){
		 layer.load(); 
      //预读本地文件示例，不支持ie8
      
    }
    ,done: function(res){
		  layer.closeAll('loading');
      //如果上传失败
      if(res.code > 0){
        return layer.msg(res.msg);
      }
      //上传成功
	    if(res.code == 0){
	var item=this.item
	item.prev("input[name=pic]").val(res.data["src"]);
		this.item.html("<img src=../"+res.data["src"]+" width=50>");
        return layer.msg(res.msg);
		
      }
    }
    ,error: function(){
		  layer.closeAll('loading');
      //演示失败状态，并实现重传
     return layer.msg('上传失败');
    
    }
  });
  
});

  
  
  
function tc(my_tit,my_url,my_width,my_height){
layer.open({
title: my_tit,
  type: 2,
  area: [my_width+'px', my_height+'px'],
  fixed: false, //不固定
  maxmin: true,
  content: my_url
});
}





	
	

	
	
	



function del(my_table,my_id) {
layer.confirm('真的删除行么', function(index){
      
		$.ajax({
			type : "POST",
			cache : true,
			url : "ajax.asp?act=dell",
			data:{"table":my_table,"id":my_id},
			error:function(){alert("fail");},
            success:function(data)
	{
		var act=data.substring(0,1);
		var info=data.substring(1);
		switch(act)
		{
			case "0":
			
			break;
			case "1":
	      location.reload();
			break;
			
				
		}
		
	}
	
	});
	
		
        layer.close(index);
      });

}	


function audit(my_id) {
layer.confirm('审核通过？', function(index){
      
		$.ajax({
			type : "POST",
			cache : true,
			url : "ajax.asp?act=audit",
			data:{"id":my_id},
			error:function(){alert("fail");},
            success:function(data)
	{
		var act=data.substring(0,1);
		var info=data.substring(1);
		switch(act)
		{
			case "0":
			
			break;
			case "1":
	      location.reload();
			break;
			
				
		}
		
	}
	
	});
	
		
        layer.close(index);
      });

}	










